#ifndef FACE_H
#define FACE_H

namespace A48 {

class Face {
  Patch  *p_;
  Hedge  *e_; // edge loop
  friend class Mesh;
  
  int index;

 public:
  Face(Hedge* e0, Hedge* e1, Hedge* e2) { reuse(e0, e1, e2); };
  Face(Hedge* e0, Hedge* e1, Hedge* e2, float v0, float v1, float v2, float v3, float v4, float v5) {
    reuse(e0, e1, e2);

    coordText[0][X] = v0;
    coordText[0][Y] = v1;
    coordText[1][X] = v2;
    coordText[1][Y] = v3;
    coordText[2][X] = v4;
    coordText[2][Y] = v5;
  };

  Patch* patch() { return p_;};
  Hedge* hedge(int k);
  Vertex* vertex(int k);
  Vector3 coordText[3];
  double area;
  Vector3 center;

  void set_index(int indx) {index = indx;};
  int get_index() { return index;};

 private:
  void set_patch(Patch* p) {p_ = p;};
  void set_hedge(int k, Hedge* h);
  void set_vertex(int k, Vertex* v);
  void set_coordText(int k, Vector3 v);

  void link_star_verts();

  Face* reuse(Hedge *e0, Hedge *e1, Hedge *e2);
};

}

#endif
